package kr.co.pension.usr.pe.re.service;

import java.util.List;

import kr.co.pension.usr.pe.re.dao.MailDao;
import kr.co.pension.usr.pe.re.vo.AddUsrVo;
import kr.co.pension.usr.pe.re.vo.PEREVo;
import kr.co.pension.utils.MailUtil;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class MailService {
	@Autowired
	public MailDao dao;
	
	
	
	@Transactional(propagation=Propagation.REQUIRED)
	public void mail0102T(AddUsrVo vo) throws Exception {
//		vo.setAu_seq(dao.mail0102Q(vo));
		
		dao.mail0102T(vo);
		String[] emailList = { vo.getAu_email() };// 메일 보낼사람 리스트 
		String emailFromAddress = "chejug@gmail.com";// 메일 보내는 사람
		String emailMsgTxt = "DM 접수되었습니다. "; // 내용
		String emailSubjectTxt = vo.getAu_name()+"님. DM 접수되었습니다.";// 제목
		emailMsgTxt = new String(emailMsgTxt.getBytes("euc-kr"), "8859_1");
		MailUtil  nMail = new MailUtil();
		// 메일보내기 
		nMail.postMail(emailList, emailSubjectTxt, emailMsgTxt, emailFromAddress);
	}
	
	
	
	public List mail0201C(AddUsrVo vo) throws Exception {
		return dao.mail0201C(vo);
	}
	
	public List mail0301C(String vo) throws Exception {
		return dao.mail0301C(vo);
	}
	
}
